package com.kakarote.examine.constant;

import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.kakarote.core.common.enums.SystemCodeEnum;
import com.kakarote.core.exception.CrmException;

import java.util.List;

/**
 * 审核状态枚举 0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交 6 创建 7 已删除 8 作废 10 忽略 即未启用审批流 11 转发 12 征求他人意见 13终止
 * TODO 20220722 此枚举已复制到 oa模块，修改本模块时请同时修改 oa模块
 */
public enum ExamineStatusEnum {
    /**
     * 通过
     */
    AWAIT(0),
    PASS(1),
    REJECT(2),
    UNDERWAY(3),
    RECHECK(4),
    UN_SUBMITTED(5),
    CREATE(6),
    REMOVE(7),
    INVALID(8),
    IGNORE(10),
    FORWARD(11),
    SEEK(12),
    /**
     * 终止
     **/
    END(13),
    /**
     * 归档
     **/
    ARCHIVE(14),
    /**
     * 抄送
     **/
    COPY(15),
    /**
     * 或签无效
     **/
    ORINVALID(16),

    //委托
    DELEGATE(17),

    /**
     * 跳过
     **/
    SKIP(18),

    /**
     * 恢复
     **/
    RESTORE(19),

    ;

    private ExamineStatusEnum(Integer status) {
        this.status = status;
    }

    private Integer status;

    public Integer getStatus() {
        return status;
    }

    public static ExamineStatusEnum valueOf(Integer status) {
        for (ExamineStatusEnum examineStatusEnum : values()) {
            if (examineStatusEnum.getStatus().equals(status)) {
                return examineStatusEnum;
            }
        }
        throw new CrmException(SystemCodeEnum.SYSTEM_NO_VALID);
    }

    public static List<Integer> unNormalStatus(){
        List<Integer> noNormalStatus = CollectionUtils.newArrayList(
                ExamineStatusEnum.INVALID.getStatus(),
                ExamineStatusEnum.END.getStatus(),
                ExamineStatusEnum.ARCHIVE.getStatus());
        return noNormalStatus;
    }

    public static List<Integer> normalStatus(){
        List<Integer> normalStatus = CollectionUtils.newArrayList(
                ExamineStatusEnum.AWAIT.getStatus(),
                ExamineStatusEnum.PASS.getStatus(),
                ExamineStatusEnum.REJECT.getStatus(),
                ExamineStatusEnum.UNDERWAY.getStatus());
        return normalStatus;
    }
}
